from sqlalchemy import *
from sqlalchemy.orm import mapper
from sqlalchemy.orm import sessionmaker
from DataSchema import *
from Repository import *

dbname = "d4"

engine = create_engine('mysql://root:@localhost/d4')

#connection = engine.connect()
#result = connection.execute("select * from REPOSITORIES")
#for row in result:
#    print str(row['id'])+","+row['provider']+","+row['distribution']+","+row['URL']+","+row['port']+","+row['username']+","+row['password']+","+row['architecture']+","+row['branch']+","+row['section']
#connection.close()

schema = DataSchema()
mapper(Repository, schema.repository_table)
Session = sessionmaker(bind=engine)
session = Session()

repo = Repository('distribution', 'Ed Jones', 'edspassword', 0,'user','password', 'arch', 'branch', 'section')
#self, id, distribution, provider, url, port, user, passwd, arch, branch, section):
session.add(repo)
session.commit()
